home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- * bits.c: Functions for manipulating bit vectors.
- * A part of OberSuite for the Commodore Amiga.
- *
- * Author: Daniel Barrett, barrett@cs.umass.edu.
- * Version: 1.0.
- * Copyright: None! This program is in the Public Domain.
- * Please share it with others.
- ***************************************************************************/
-
- #include "bits.h"
-
- /* Given a bit vector, turn on the nth bit (counting from 0). */
-
- void FlipOn(BITS bitfield[], int n)
- {
- bitfield[n/BITFIELD_WIDTH] |= (1 << (n % BITFIELD_WIDTH));
- }
-
-
- /* Given a bit vector, set all of its bits to 0. */
-
- void ClearBitfield(BITS bitfield[])
- {
- int i;
- for (i=0; i<BITFIELD_LENGTH; i++)
- bitfield[i] = (BITS)0;
- }
-
-
- /* Given a bit vector, determine whether or not a given bit is on. */
-
- BOOL BitOn(BITS bitfield[], int bit)
- {
- return(bitfield[bit/BITFIELD_WIDTH] & (1 << (bit % BITFIELD_WIDTH)));
- }
-